.if (0)

***************************************************

Get Filenames

Author: William C. Coleman

Start Date: 12 April 1988

Notice: Copyright (C) 1988, BlasterSoft, William C. Coleman

page 1 constants,ramsect,InitDirRead,NextDirEntry

page 2 GetFilenames

***************************************************

.endif

buffer = ???? ;address of buffer

; PAGES is the number of pages (256 byte blocks) that the

; buffer is long. i.e. a 1K buffer would be PAGES = 4

PAGES = ?

.ramsect

temp: .block 1

type2Look4: .block 1

.psect

InitDirRead:

; Version independent version of Get1stDirEntry

; Return: r5 - diskBlkBuf+2 (i.e. 1st dir entry)

; X - disk error

lda version

cmp #$13

bcs 10$

jmp $c9f7 ;alternate call for V1.2

10$:

jmp Get1stDirEntry

NextDirEntry:

; Version independent version of GetNxtDirEntry

; return: r5 - points to next directory entry

; Y - non-zero if no more entries

; X - disk error

lda version

cmp #$13

bcs 10$

jmp $ca10 ;alternate call for V1.2

10$:

jmp GetNxtDirEntry

GetFilenames:

: Loads buffer beginning at buffer with the

; unscratched filenames on the active disk.

; Max # of filenames is (PAGES*256)/17.

; pass: A - Filetype to look for - $ff means all

; return: Y - # of files loaded

; X - Disk Error, NULL = All OK

sta type2Look4

jsr OpenDisk

txa

bne 10$

jsr InitDirRead

txa

beq 20$

10$:

rts

20$:

LoadW r0,PAGES*256 ;initialize buffer to zeros

LoadW r1,buffer

jsr ClearRam

LoadW r15,buffer-3-17 ;initialize buffer pointer

LoadB temp,0 ;filename counter

30$:

ldy #0

lda (r5),y ;get commie filetype

beq 60$ ;scratched -- ignore

lda type2Look4

bmi 35$ ;look for everything

ldy #22 ;geos filetype offset

cmp (r5),y

bne 60$ ;not correct filetype

35$:

AddVW 17,r15 ;r15 holds address in buffer

ldy #3 ;r15 is 3 less

40$:

lda (r5),y ;get a byte

cmp #$a0 ;shifted space

beq 50$

cmp #' ' ;this will remove chars

bcs 45$ ;Geos can't print. Remove

lda #'*' ;these 3 lines if not needed

45$:

sta (r15),y ;store in buffer

iny

cpy #3+16

bne 40$

50$:

inc temp

lda temp

cmp #(PAGES*256)/17 ;max # if files

beq 70$ ;buffer is maxed out

60$:

jsr NextDirEntry

txa

bne 80$

tya

beq 30$ ;get another name

70$:

ldx #0 ;X = 0, there's no error

80$: